Returns a pointer to an occurrence of lpvKey in the array pointed to by lpvBase. If lpvKey is not found, the function returns NULL. If the array is not in ascending sort order or contains duplicate records with identical keys, the result is unpredictable.
The BSearch() function performs a binary search of a sorted array of nNum elements, each of nWidth bytes in size. The lpvBase value is a pointer to the base of the array to be searched, and lpvKey is the value being sought. The ptcCompareFunc parameter is a string indicating a user-supplied script routine that compares two array elements and returns a value specifying their relationship. BSearch() calls the ptcCompareFunc routine one or more times during the search, passing pointers to two array elements on each call. The compare routine compares the elements, then returns one of the following values:
Return < 0: lpvElem1 less than lpvElem2
Return == 0: lpvElem1 equivalent to lpvElem2
Return > 0: lpvElem1 greater than lpvElem2
Implements a quick-sort algorithm to sort an array of nNum elements, each of nWidth bytes. The argument lpvBase is a pointer to the base of the array to be sorted. QSort() overwrites this array with the sorted elements. The argument ptcCompareFunc is a string indicating a user-supplied script routine that compares two array elements and returns a value specifying their relationship. QSort() calls the ptcCompareFunc routine one or more times during the sort, passing pointers to two array elements on each call:
pcCompareFunc( (LPVOID) lpvElem1, (LPVOID) lpvElem2 );
The routine must compare the elements, then return one of the following values:
Return < 0: lpvElem1 less than lpvElem2
Return == 0: lpvElem1 equivalent to lpvElem2
Return > 0: lpvElem1 greater than lpvElem2
The array is sorted in increasing order, as defined by the comparison function. To sort an array in decreasing order, reverse the sense of “greater than” and “less than” in the comparison function.
Returns FALSE if the sort fails due to an invalid ptcCompareFunc parameter.